module Admin
  class PhotosController < Admin::ApplicationController
    before_action :set_photo, only: [:show, :destroy]

    def index
      @photos = Photo.recent.includes(:user).paginate(page: params[:page], per_page: 20)
    end

    def destroy
      @photo.destroy
      redirect_to(admin_photos_url)
    end

    private

    def set_photo
      @photo = Photo.find(params[:id])
    end
  end
end
